IF EXISTS ( SELECT  *
            FROM    dbo.sysobjects
            WHERE   id = OBJECT_ID(N'[CGO_EventGameDelete]')
                    AND OBJECTPROPERTY(id, N'IsProcedure') = 1 ) 
  DROP PROCEDURE CGO_EventGameDelete
GO

SET QUOTED_IDENTIFIER ON
SET ANSI_NULLS ON
GO


CREATE PROCEDURE dbo.CGO_EventGameDelete
  @PortalID INT,
  @EventID INT ,
  @GameID INT
AS 
  IF @GameID IS NULL OR @GameID<0
  BEGIN
  	SET @GameID = 0
  END 
  
  DELETE  FROM dbo.CGO_EventGame
  WHERE   PortalID = @PortalID
          AND EventID = @EventID
          AND ( @GameID = 0
                OR GameID = @GameID
              )  
GO
